public with sharing class DataWithApexComponentController {
    public DataWithApexComponentController() {

    }

    @AuraEnabled(cacheable=true)
    public static List<sObject> searchStudents(String studentName) {
        System.debug('进入searchStudents方法，studentName: ' + studentName);
        try {
            
            String soql = 'select Student_Name__c, Sex__c, School_Fee__c, Teacher__c from Student__c';
            if(String.isNotBlank(studentName)) {
                soql += ' where Student_Name__c = :studentName';
            }
            List<sObject> stuList = Database.query(soql);
            System.debug('查询结果: ' + stuList);
            return stuList;
        } catch (Exception e) {
            System.debug(LoggingLevel.ERROR, '查询出错了，' + e);
            throw new AuraHandledException(e.getMessage());
        }
    }

}